<template>
	<view class="com-float-button" :style="{ bottom: parseInt(bottom) + 'rpx' }">
		<!-- <view :class="{ mark: show }"></view> -->
		<view :class="show ? 'list-active' : 'list'">
			<view class="list-item" :class="{ show: show }"
				:style="{ width: parseInt(size) + 'rpx', height: parseInt(size) + 'rpx', background: item.background ? item.background : background }"
				v-for="(item, index) in list" :key="index" @tap="tap(item)">
				<template v-if="item.customer==true">
					<button @click="kf()" class="btn">
						<image :src="item.icon" :style="{height:item.height,width:item.width}" mode="heightFix" />
					</button>
				</template>
				<template v-else>
					<image :src="item.icon" :style="{height:item.height,width:item.width}" mode="heightFix" />
				</template>

			</view>
		</view>
		<view class="list-item show no-mb" :style="{ width: parseInt(size) + 'rpx', height: parseInt(size) + 'rpx'}"
			@click="up()" style="background-color: rgba(255, 255, 255, 1);" v-if="false">
			<image class="icon" :src="show ? closeIcon : openIcon" mode="aspectFit"></image>
			<!-- <text class="name"
				:style="{ fontSize: parseInt(fontSize) + 'rpx' }">{{ show ? closeText : openText }}</text>
			<u-icon :name="!show?'plus':'arrow-upward'" size="50rpx" color="#000" /> -->
		</view>
	</view>
</template>

<script>
	import {
		goNav
	} from '@/lib/Comment.js'
	export default {
		props: {
			list: {
				type: Array,
				default: () => [{
						customer: true,
						background: 'rgb(255,255,255)',
						icon: '/static/icon/indexkf.png',
						height: '70rpx',
						},
					// }, {
					// 	customer: false,
					// 	background: 'rgb(255,255,255)',
					// 	icon: '/static/icon/indexz.png',
					// 	height: '60rpx',
					// 	url: "/pages/Copywriting/index"
					// },
					{
						customer: false,
						background: 'rgb(255,255,255)',
						icon: '/static/icon/ewm.png',
						height: '60rpx',
						url: '/pages/sub/user/erwim'
					}
				]
			},
			// 离屏幕底部距离
			bottom: {
				type: [String, Number],
				default: '150rpx'
			},
			// 图标大小，即按钮宽高rpx
			size: {
				type: [String, Number],
				default: '85rpx'
			},
			fontSize: {
				type: [String, Number],
				default: '20rpx'
			},
			background: {
				type: String,
				default: 'rgba(0, 0, 0, 0.7)'
			},
			closeIcon: {
				type: String,
				default: '/static/images/up.png'
			},
			openIcon: {
				type: String,
				default: '/static/images/plus.png'
			},

		},
		data() {
			return {
				show: true
			};
		},
		methods: {
			kf() {
				wx.openCustomerServiceChat({
					extInfo: {
						// url: 'https://work.weixin.qq.com/kfid/kfc373553bc54f155e8'
						url: 'https://work.weixin.qq.com/kfid/kfc943a1459a5d71aac'
					},
					corpId: 'wwb223d8888e62d795',
					success(res) {}
				})
			},
			tap(item) {
				if (item.id == 1) {
					console.log("111111111111");
					uni.navigateToMiniProgram({
						appId: 'wx6b4bcb937309cd95', // 跳转目标小程序的id
						path: 'pages/index/index', // 目标小程序的页面路径

						success(res) {
							// 打开成功
						}
					})
				} else {
					goNav(item.url)
				}
			},
			up() {
				uni.pageScrollTo({
					scrollTop: 0
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.com-float-button {
		position: fixed;
		right: 20rpx;
		z-index: 999;

		.mark {
			z-index: -1;
			position: fixed;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;

			transition: all 0.3s linear;
		}

		.list-active {
			position: absolute;
			bottom: 80rpx;
			right: 6rpx;
			transform: scale(1);
			transition: all 0.3s ease-in-out;
		}

		.list {
			position: absolute;
			bottom: 0;
			left: 0;
			transform: scale(0);
			transform-origin: bottom;
			opacity: 0;
			transition: all 0.3s ease-in-out;
		}

		.list-item {
			margin-bottom: 20rpx;
			border-radius: 50%;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			color: #fff;

			.iconfont {
				line-height: 1;
				font-size: 45rpx;
			}

			&.no-mb {
				margin-bottom: 0;
			}

			.icon {
				height: 40rpx;
			}

			.name {
				line-height: 1;
				margin-top: 8rpx;
			}
		}
	}

	.btn {
		background: transparent;
		border: none;
		padding: 0;

		&::after {
			border: none;
		}

	}
</style>
